if(!$config.IsPC()){
    location.href = 'index-m.html'
}else{
    document.body.style.display = 'block';
}
$(function () {
    var player = videojs('video', {poster : __uri('/web/views/index/img/video-bg.jpg')});

    var mySwiper = new Swiper ('.plan-container', {
        loop: true,
        speed:500,
        autoplay : true,
        direction: 'horizontal',
        slidesPerView : 3,
        centeredSlides : true,
        // 如果需要分页器
        pagination: {
            el: '.plan-pagination',
            clickable :true,
        },
    });

    /*var reportSwiper = new Swiper ('.report-container', {
        loop: true,
        speed:500,
        autoplay : true,
        direction: 'horizontal',
        centeredSlides : true,
        // 如果需要分页器
        pagination: {
            el: '.report-pagination',
            clickable :true,
        },
    });*/

    //自动偏移
    (function () {
        var index = 0,
            func = function(){
                if(index>=4){
                    index = 0
                }else{
                    index++
                }
                $('.five-scenes .more').css('left',index*240-20+'px');
                $('.five-scenes .li img').hide()
                $('.five-scenes .li').eq(index).find('img').show()
            },
            time = setInterval(func,2000)
        // func();

        $('.five-scenes .li').mouseenter(function () {
            clearInterval(time);
            index = $(this).index()-1;
            func();
        })
        $('.five-scenes ul').mouseleave(function () {
            time = setInterval(func,2000)
        })

        $('.five-scenes .to-sign').click(function () {
            location.href = 'sign-up.html?city='+index
        })
    })();

    //dom初始化
    function DomStart(){
        //弹出框
        (function () {
            var box;
            $('.box-explain-open').click(function () {
                var type = $(this).data('type'),
                    tit = $(this).data('tit');

                $('.box-explain .tit').text(tit);
                $('.box-explain img').hide();
                $('.box-explain img').eq(type-1).show()

                box = layer.open({
                    type: 1,
                    title: false,
                    closeBtn: 0,
                    area: '1000px',
                    skin: 'layui-layer-nobg', //没有背景色
                    shadeClose: true,
                    content: $('.box-explain')
                });
            })

            $('.box-close-btn').click(function () {
                layer.close(box)
            })
        }());
    }


    //初始化
    var web = new Vue({
        el : '#vue',
        data () {
            return {
                lists : '',
                first : '',
                players : '',
                player_index : 0
            }
        },
        created(){
            this.getList();
        },
        mounted(){
            DomStart();
        },
        methods : {
            getList (){
                var _this = this;
                $.ajax({
                    url : $config.host()+'/NBASearch/GetInformation',
                    dataType : 'json',
                    data : {
                        type  : 'DailyPopularityList',
                        pageSize : 9,
                        pageNum : 1
                    },
                    success(json){
                        var datas = json.playerList;
                        if(json.success && json.playerList.length > 0){
                            _this.lists = datas;
                            _this.first = datas[0];
                        }
                    }
                })



                $.ajax({
                    url : $config.host()+'/NBASearch/GetInformation',
                    dataType : 'json',
                    data : {
                        type  : 'GetThreeBestVideos'
                    },
                    success(json){
                        var datas = json.playerList;
                        if(json.success && datas.length > 0){
                            _this.players = json.playerList;
                        }
                    }
                })
            },
            new_xiu_over (index){
                this.player_index = index;
            },
            player_video (index) {
                var box;

                $('.video-play-box video').hide();
                $('.video-play-box video').eq(index).show()

                box = layer.open({
                    type: 1,
                    title: false,
                    closeBtn: 0,
                    area: ['1000px', '600px'],
                    skin: 'layui-layer-nobg', //没有背景色
                    shadeClose: true,
                    content: $('.video-play-box')
                });

                document.querySelectorAll('.video-play-box video')[index].play()
            }
        }
    })
})

